'''
Created on Jul 31, 2011
Funciton used to test atmel powered temperature logger 
@author: Andrzej
'''

import os
import re 
import numpy as np
import matplotlib.pyplot as plt
from Daq328p import Daq328p 
import time

def GetReading(Ard):
    return 0    

if __name__ == '__main__':
    D = Daq328p(port=6)    
    D.send("X")
    dt = (256*1024)/16e6
    print "Reseting timer"
    t = []
    T = []
    for i in range(60):     
        tmp = (D.GetThermocoupleReading())
#        print tmp        
        t.append(tmp[0]*dt)
        T.append(tmp[1]*5.0/1024.0)
        print "%d  %d  %.3f" % (i, t[i], T[i])
        time.sleep(1)
        
    data = np.array([t,T]).transpose()
    os.chdir('E:\home\data')
    np.save('thermocouple', data)
    plt.plot(t,T,'-o')
    plt.show()
    print "All done"
       
    